package com.zsrt.java.day20161227.wrl.homework;

import java.util.Arrays;
import java.util.Scanner;

import org.junit.Test;

import com.zsrt.java.day20161227.wrl.homework.demo01.RedEnvelope;
import com.zsrt.java.day20161227.wrl.homework.demo02.Welfare02;
import com.zsrt.java.day20161227.wrl.homework.demo03.Lottery;
import com.zsrt.java.day20161227.wrl.homework.demo06.Summary;

public class HomeworkTest {
	
	/**
	 * 测试 福利彩票方法
	 * @throws Exception
	 */
	@Test
	public void welfareTest() throws Exception {
		Scanner input = new Scanner(System.in);
		boolean judge = true;
		while(judge){
			System.out.println("请输入数字：000~999");
			
			//1 让用户从键盘上上输入数字
			String num = input.next();	
			
//			boolean isWinning = Welfare01.welfare(num);
			boolean isWinning = Welfare02.welfare(num);
			if(isWinning){
				System.out.println("恭喜你，中奖了！");
			}else{
				System.out.println("很遗憾，没有中奖！");
			}
			System.out.println("--------是否结束循环（y/n）---------");
			String end = input.next();
			if(end.equalsIgnoreCase("y")){
				judge = false;
			}
		}
		System.out.println("程序结束运行...");
		input.close();
	}
	
	/**
	 * 测试斗地主算法
	 */
	@Test
	public void redEnvelopeTest(){
		Scanner input = new Scanner(System.in);
		boolean judge = true;
		while(judge){
			System.out.println("请输入红包金额：");
			double money = input.nextDouble();	
			System.out.println("请输入红包个数：");
			int people   = input.nextInt();
			
			//获取红包数组
			double[]moneys = RedEnvelope.redEnvelope02(money, people);
			System.out.println("红包总金额："+money+" ; 个数为："+people);
			System.out.println(Arrays.toString(moneys));
			System.out.println("是否继续发红包...(y/n)");
			String end = input.next();
			
			//判断是否继续发红包
			if(end.equalsIgnoreCase("n")){
				judge = false;
			}
		}
		System.out.println("..怎么走啦，继续发红包啊....");
		input.close();
	}
	
	/**
	 * 测试 买码1~49
	 */
	@Test
	public void lotteryTest(){
		Scanner input = new Scanner(System.in);
		boolean judge = true;
		while(judge){
			System.out.println("请输入你购买的号码：");
			int num = input.nextInt();
			boolean result = Lottery.lottery03(num);
			if(result){
				System.out.println("中奖了，特码是："+num);
			}else{
				System.out.println("很遗憾没中奖！");
			}
			System.out.println("是否继续买码...(y/n)");
			String end = input.next();
			
			//判断是否继续买码
			if(end.equalsIgnoreCase("n")){
				judge = false;
			}
		}
		System.out.println("程序结束....");
		input.close();
	}
	
	/**
	 * 测试 Summary.peoCount(String[])
	 */
	@Test
	public void peoCountTest(){
		String[] arrays = {"55","sd","dd","abc",null,null,null};
		int xx = Summary.peoCount(arrays);
		System.out.println(xx);
	}

}
